#ifndef	DLIST_H
#define	DLIST_H

#include	"typedef.h"

struct _DList;
typedef struct _DList DList;

struct _DListEntry;
typedef struct _DListEntry DListIter;

DList *dlist_create(size_t size, DataAllocFunc alloc_func, DataDestroyFunc destroy_func, void *ctxt);
void dlist_destroy(DList* thiz);
size_t dlist_count(DList *thiz);

DListIter *dlist_push_front(DList *thiz, void *data);
DListIter *dlist_push_back(DList *thiz, void *data);
void dlist_pop_front(DList *thiz);
void dlist_pop_back(DList *thiz);
DListIter *dlist_insert(DList *thiz, DListIter *iter, void *data);
void dlist_remove(DList *thiz, DListIter *iter);

DListIter *dlist_head(DList *thiz);
DListIter *dlist_tail(DList *thiz);

void dlist_for_each(DList *thiz, DListInter *start, DListInter *end, 
		Direct direct, DataVisitFunc visit_func, void *ctxt);
DListIter *dlist_find(DList *thiz, DListInter *start, DListInter *end, 
		Direct direct, DataCmpFunc cmp_func, void *ctxt);

DListIter *dlist_entry_next(DList *thiz, DListIter *iter);
void *dlist_entry_value(DList *thiz, DListEntry *entry);
void dlist_entry_swap(DList *thiz, DListIter *a, DListEntry *b);
Ret dlist_entry_valid(DList *thiz, DListIter *entry);


#endif
